﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ThuySan.Models;

namespace ThuySan.Controllers
{
    public class HomeProductController : Controller
    {
        UnitOfWork unitOfWork = new UnitOfWork();
        //
        // GET: /Product/

        public ActionResult Detail(int id)
        {
            var pro = unitOfWork.ProductRepository.Select(c => c.ProductId == id, "Category.CategoryPropertys.Property,Images,ProductPropertys").FirstOrDefault();
            if (pro == null)
            {
                return RedirectToAction("NotFound", "Home");
            }
            pro.Viewer = (pro.Viewer ?? 0) + 1;
            unitOfWork.AcceptChanges();
            return View(pro);
        }

    }
}
